#define _CRT_SECURE_NO_WARNINGS
//https://leetcode.cn/problems/min-stack/solutions/

class MinStack {
public:
    MinStack() {

    }


    void push(int val) {
        num.push(val);
        if (NumMin.empty() || val <= NumMin.top())
        {
            NumMin.push(val);
        }

    }

    void pop() {

        if (num.top() == NumMin.top())
            NumMin.pop();
        num.pop();
    }


    int top() {
        return num.top();
    }

    int getMin() {
        return NumMin.top();
    }
    stack<int> num;
    stack<int> NumMin;
};